// ActionScript file

import com.adobe.serialization.json.JSON;

import mx.collections.ArrayCollection;
import mx.controls.Alert;


			[Bindable] public var pieData:ArrayCollection = new ArrayCollection();
			
			[Bindable] public var responseJSON:Object;
			
			private function callWebService():void{
			
				var loader:URLLoader = new URLLoader();
				var header1:URLRequestHeader = null;
				header1 = new URLRequestHeader("pragma", "no-cache");
				var request:URLRequest = new URLRequest("http://java.cdaandino.com/rtm/MMILTitanium/FlexService.svc/FlexIndicador");
				request.requestHeaders.push(header1);
				request.method = URLRequestMethod.POST;
				
				
				request.data = '<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"DEP":"C4","IND":"AVANCE"}</string>';
				request.contentType = "text/xml";
				loader.addEventListener(Event.COMPLETE, onLoaded);
				loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
		
		
				try{
					loader.load(request);
				}catch(error:ArgumentError){
					trace("An ArgumentError has occurred.");
					Mask.close(); 
				}catch (error:SecurityError) 
				{ 
				    trace("A SecurityError has occurred."); 
				    Mask.close();
				}
		
			
			}
			
			
			
			private function onLoaded(e:Event):void {
				pieData = new ArrayCollection();
				var repuesta:String=e.target.data;
				repuesta = repuesta.replace("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">","");
				repuesta = repuesta.replace("</string>","");
						
				responseJSON =  JSON.decode(repuesta);
				
				pieData.addItem({label:"Avance", data:responseJSON.DAT.Avance});
				pieData.addItem({label:"Objetivo", data:responseJSON.DAT.Objetivo});
				
				Mask.close();
			}

			private function ioErrorHandler(event:IOErrorEvent):void
            {
                trace("ioErrorHandler: " + event);
                Mask.close();
            }